export default function bar() {
  const curMousePos = {
    x: 0,
    y: 0,
  };
  const myCanvas = document.querySelector("#myCanvas");
  myCanvas.addEventListener("mousemove", mouseMove);
  const ctx = myCanvas.getContext("2d");

  var drawLineGrid = () => {
    ctx.beginPath();
    ctx.lineTo(10, 10);
    ctx.lineTo(100, 10);
    ctx.lineTo(55, 100);
    ctx.lineTo(10, 10); // 回到起始点图形闭合
    ctx.closePath();
    let isPointIn = ctx.isPointInPath(curMousePos.x, curMousePos.y);
    if (isPointIn) {
      ctx.fillStyle = "#ff4f0288";
      ctx.fill();
      myCanvas.style.cursor = "pointer";
    } else {
      myCanvas.style.cursor = "default";
      ctx.fillStyle = "blue";
      ctx.fill();
    }
  };



  


  function mouseMove(e) {
    curMousePos.x = e.clientX;
    curMousePos.y = e.clientY;
  }
  main();
  function main() {
    drawLineGrid();
    requestAnimationFrame(main);
  }
}
